<?php

declare(strict_types=1);
/**
 * FastApp.
 * 9/26/24
 * @Author deepsea159
 * @Contact telegram:deepsea159
 */

namespace App\Fastapp\Api\Controller\Account;


use App\Fastapp\Api\Controller\ApiController;
use App\Fastapp\Api\Service\Account\WalletService;
use App\Fastapp\Aspect\ApiAuth;
use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\GetMapping;
use Hyperf\HttpServer\Annotation\PostMapping;
use Psr\Http\Message\ResponseInterface;

#[Controller(prefix: "api/wallet"), ApiAuth]
class WalletController extends ApiController
{
    #[Inject]
    public WalletService $service;

    #[GetMapping('list')]
    public function list(): ResponseInterface
    {
        return $this->success($this->service->list($this->request->all()));
    }

    #[GetMapping('detail')]
    public function detail(): ResponseInterface
    {
        return $this->success($this->service->detail($this->request->input('symbol')));
    }

    #[PostMapping('fundsTransfer')]
    public function fundsTransfer(): ResponseInterface
    {
        return $this->success($this->service->fundsTransfer($this->validate([
            'symbol' => 'required',
            'amount' => 'required',
            'account' => 'required|in:spot,futures,contract,finance',
        ])));
    }

    #[PostMapping('accountTransfer')]
    public function accountTransfer(): ResponseInterface
    {
        return $this->success($this->service->accountTransfer($this->validate([
            'symbol' => 'required',
            'amount' => 'required',
            'to_user_id' => 'required',
        ])));
    }
}